package com.thor.palmmall.card.member.impl;

import com.thor.commons.exception.ThorServiceException;
import com.thor.palmmall.card.common.SBaseServiceImpl;
import com.thor.palmmall.card.member.CheckAccountRequest;
import com.thor.palmmall.card.member.CheckAccountResponse;
import com.thor.palmmall.card.member.OpenCardRequest;
import com.thor.palmmall.card.member.OpenCardResponse;
import com.thor.palmmall.card.member.SMemberService;
import com.thor.palmmall.card.member.SSimpleCard;
import com.thor.palmmall.card.member.SaveNewMemberRequest;
import com.thor.palmmall.card.member.SaveNewMemberResp;

/**
 * @author liyang
 * @since 1.0
 */
public class SMemberServiceImpl extends SBaseServiceImpl implements SMemberService {

  @Override
  public boolean checkAccountExist(CheckAccountRequest request) throws ThorServiceException {
    CheckAccountResponse resp = post("/account/check", request, CheckAccountResponse.class);
    if (resp.getSuccess()) {
      return true;
    }
    return false;
  }

  @Override
  public String save(SaveNewMemberRequest request) throws ThorServiceException {
    SaveNewMemberResp resp = post("/mbr/saveNew", request, SaveNewMemberResp.class);
    return resp.getValue();
  }

  @Override
  public SSimpleCard openCard(OpenCardRequest request) throws ThorServiceException {

    OpenCardResponse response = post("/card/openCard", request, OpenCardResponse.class);
    return response.getCard();
  }

}
